function showModal(e) {
  console.log($(e).prop('type'))
  if($(e).prop('type')=='alert'){
    $('.mask').show()
    $('.mode_box').show()
  }
}
function hideModal() {
  $('.mask').hide()
  $('.mode_box').show()
}
function setMenu(status=true) {
  if($('.menu').hasClass('icon-menu')&&status){//显示
    $('.menu').removeClass('icon-menu').addClass('icon-close')
    $('.header_nav_bar').addClass('flex-x-y-vertical')
    $('.header').addClass('header_bg_white')
      $(".header .logo").attr('src','/template/assets/image/logo.png')
  }else{//隐藏
    $('.menu').removeClass('icon-close').addClass('icon-menu')
    $('.header_nav_bar').removeClass('flex-x-y-vertical')
    $('.header').removeClass('header_bg_white')
    if(document.documentElement.scrollTop||document.body.scrollTop>45){
      $(".header .logo").attr('src','/template/assets/image/logo.png')
    }else{
      $(".header .logo").attr('src','/template/assets/image/logo01.png')
    }
  }
}
$('.setui').click(function(){
  if($(this).children('ul').hasClass('disp-none')){
    $(this).children('ul').removeClass('disp-none').addClass('disp-block')
    $(this).children('a').children('span').css({'transform':'rotate(180deg)','transition':'all 0.2s ease 0s'})
  }else{
    $(this).children('ul').removeClass('disp-block').addClass('disp-none')
    $(this).children('a').children('span').css({'transform':'rotate(360deg)','transition':'all 0.2s ease 0s'})
  }
});
function checkHeight(){//屏幕高度检查，底部置底
  $('.footer').removeClass('p-f');
  if($(window).height()>$(document.body).outerHeight(true)){
    $('.footer').addClass('p-f')
  }
}
$(function () {
  
  let navList = $('.header_nav_bar').children();
  let navChildList = $('.nav_ul').children();
  setTimeout(() => {
    let {href,host}=window.location;
    let url = href.split(host)
    url = url[url.length-1];
    console.log("url",url)
    if(url!='/about'&&url!='/'){
      $(".header .logo").attr('src','/template/assets/image/logo.png')
    }
    for(let i=0,len=navList.length;i<len;i++){
      if(url==$(navList[i]).find('a').attr('href')){
        console.log($(navList[i]));
        $(navList[i]).addClass('active');
      }
    }
    if(url=='/about'){
      $(".header .logo").attr('src','/template/assets/image/logo01.png')
    }
  for(let i=0,len=navChildList.length;i<len;i++){
    if(url==$(navChildList[i]).find('a').attr('href')){
      $(navChildList[i]).addClass('active').parent().parent().addClass('active');
    }
  }
  checkHeight();
  console.log($(window).height(),$(document.body).outerHeight(true));　//浏览器时下窗口文档body的总高度
  }, 30);
  for(let i=0,len=navList.length;i<len;i++){
    $(navList[i]).bind('click',function(e){
      console.log();
      if(!$(this).hasClass('unset')&&$($(this).find('a')[0]).attr('href')!='javascript:;'){
        $('.header_nav_bar li').removeClass('active');
        $(this).addClass('active');
      }
      // e.stopPropagation();    //  阻止事件冒泡
    })
  }
  for(let i=0,len=navChildList.length;i<len;i++){
    $(navChildList[i]).bind('click',function(e){
      console.log(i)
      $('.header_nav_bar li').removeClass('active');
      $(this).addClass('active').parent().parent().addClass('active');
      e.stopPropagation();    //  阻止事件冒泡
    }).bind('mouseleave',function(params) {
      if($(this).parent().parent().hasClass('unset')){
        $(this).parent().parent().removeClass('active');
      }
    })
  }
  console.log(navList)
})
//监听浏览器宽度的改变
window.onresize = function(){
  changeMargin();
};
function changeMargin(){
  //获取网页可见区域宽度
  var docWidth = document.body.clientWidth;
  console.log(docWidth);
  if(docWidth >375){
    setMenu(false)
  }
}



if($('#center').hasClass('bg_transparent')){
  window.addEventListener("scroll", this.handleScroll);
}
function handleScroll() {
  let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  let offsetTop = document.querySelector(".qualification").offsetTop;
  // console.log(scrollTop,offsetTop,scrollTop-offsetTop,$('.header').height());
  if(offsetTop-scrollTop>$('.header').height()){
      $('.header').removeClass('bg_transparent')
  }else{
      $('.header').addClass('bg_transparent')
  }
}